<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/25
 * Time: 15:49
 */

namespace App\DAO;

use App\Department;
class DepartmentDAO
{
    public static function getAll(){
        return Department::all();
    }

    public static function create($data){
        return Department::create($data);
    }

    public static function getOne($id){
        return Department::find($id+0);
    }

    public static function modify($id,$data){
        $dept = Department::find($id+0);
        if(!$dept) return false;

        $dept->name = $data['name'];
        $dept->address = $data['address'];
        $dept->telephone = $data['telephone'];
        $dept->save();
        return $dept;
    }

    public static function delete($id){
        return Department::destroy($id+0);
    }
}